package com.example.back.controller;


import com.example.back.dto.MenuTree;

import com.example.back.dto.req.RoleReq;
import com.example.back.dto.req.RolesCommitSaveReq;
import com.example.back.dto.resp.RolesResp;
import com.example.back.service.SysRolesService;
import com.example.common.support.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "角色管理")
@RequestMapping("/DSys/Role")
public class RoleController {

    @Resource
    private SysRolesService sysRolesService;

    @ApiOperation(value = "获取角色管理列表", notes = "获取角色管理列表")
    @PostMapping(value = "/list")
    public Result<PageInfo<RolesResp>> list(@RequestBody RoleReq req) {
        return Result.success(sysRolesService.list(req));
    }


    @ApiOperation(value = "模块管理", notes = "模块管理")
    @PostMapping(value = "/modulelist")
    public Result<List<MenuTree>> modulelist(@RequestBody RoleReq req){
        return Result.success(sysRolesService.modulelist(req));
    }


    @ApiOperation(value = "新增和修改角色管理权限", notes = "新增和修改角色管理权限")
    @PostMapping(value = "/commitSave")
    public Result<Object> commitSave(@RequestBody RolesCommitSaveReq req) {
        return Result.success(sysRolesService.commitSave(req));
    }


    @ApiOperation(value = "角色管理删除", notes = "角色管理删除")
    @PostMapping(value = "/commitDel")
    public Result<Object> commitDel(@RequestBody RoleReq req) {
        return Result.success(sysRolesService.commitDel(req));
    }

}
